/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.beautycenter.view;

import br.com.beautycenter.Funcionalidades.Data;
import br.com.beautycenter.Funcionalidades.Swing;
import br.com.beautycenter.Funcionalidades.Validacoes;
import br.com.beautycenter.DAO.PersisteContraIndicacao;
import br.com.beautycenter.bean.ContraIndicacao;
import br.com.beautycenter.bean.Cliente;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

/**
 *
 * @author user
 */
public class CadastroContraIndicacao extends javax.swing.JDialog {

    CadastroCliente cadastroPaciente;
    PersisteContraIndicacao persisteContraIndicacao = new PersisteContraIndicacao();
    
    List<ContraIndicacao> listaContraIndicacoes = new ArrayList<ContraIndicacao>();
    int operacao = -1;
    int posicao = -1;
    
    ContraIndicacao contra = new ContraIndicacao();
    Cliente cliente;

    
    
    /**
     * Inicialmente os botões ativos serão: <br/> btnNovo<br/> btnEditar<br/>
     * btnPesquisar<br/> btnSair<br/>
     */
    public void ativarBotoesIniciar() {
        Swing.desativarCampos(jPainelBotoes.getComponents());
        configuracoesIniciaisDados();

        //se a lista estiver vazia, cria um novo
        if (listaContraIndicacoes.isEmpty()) {
            novo();
            btnCancelar.setEnabled(false);
        } else if (posicao < 0) {
            btnNovo.setEnabled(true);
            btnPesquisar.setEnabled(true);
            btnSair.setEnabled(true);
        } else {
            btnNovo.setEnabled(true);
            btnPesquisar.setEnabled(true);
            btnSair.setEnabled(true);
            btnEditar.setEnabled(true);
            btnExcluir.setEnabled(true);
        }
    }
    
    public void ativarBotoesNovoEditarExcluir() {
        Swing.desativarCampos(jPainelBotoes.getComponents());
        btnSalvar.setEnabled(true);
        btnCancelar.setEnabled(true);
        btnSair.setEnabled(true);
    }
    
    public void limparCampos() {
        Swing.zerarCampos(jPanelDados.getComponents());
    }
    public void desativarCampos() {
        Swing.desativarCampos(jPanelDados.getComponents());
    }
    
    
    public void ativarCampos() {
        Swing.ativarCampos(jPanelDados.getComponents());
    }
    /**
     * Caso o radioSim esteja selecionado o campo texto correspondente é ativado.
     * @param radio
     * @param campo 
     */
    public void ativarCampo(JRadioButton radio, JTextField campo){
        if(!radio.isSelected()){
            campo.setEnabled(false);
            campo.setText("");
        }else{
            campo.setEnabled(true);
        }
    }
    
    public void editar() {
        operacao = 1;
        exibirContraIndicacao();
        ativarCampos();
        ativarBotoesNovoEditarExcluir();

        contra = new ContraIndicacao();
        contra = listaContraIndicacoes.get(posicao);
    }
    
    /**
     * `Remove o perfil da lista e atualiza o paciente.
     */
    public void excluir(){
        contra = listaContraIndicacoes.get(posicao);
        contra = persisteContraIndicacao.retornarPerfilPeloId(contra);
        try{
            persisteContraIndicacao.deletar(contra);
            listaContraIndicacoes.remove(posicao);
        }catch(Exception ex){
            System.out.println("ex: " + ex.getMessage());
            ex.printStackTrace();
        }
        
        posicao = -1;
        limparCampos();
        desativarCampos();
        ativarBotoesIniciar();
    }
    public void exibirContraIndicacao() {
        RGravidezSim.setSelected(listaContraIndicacoes.get(posicao).isGravidez());
        RGravidezNao.setSelected(!listaContraIndicacoes.get(posicao).isGravidez());
        txtDescricaoGravidez.setText(listaContraIndicacoes.get(posicao).getTipoGravidez());
        
        RInfeccoesLocaisSim.setSelected(listaContraIndicacoes.get(posicao).isInfeccoesLocais());
        RInfeccoesLocaisNao.setSelected(!listaContraIndicacoes.get(posicao).isInfeccoesLocais());
        txtDescricaoInfeccoes.setText(listaContraIndicacoes.get(posicao).getTipoInfeccoesLocais());
        
        RCirculacaoInadequadaSim.setSelected(listaContraIndicacoes.get(posicao).isCirculacaoInadequada());
        RCirculacaoInadequadaNao.setSelected(!listaContraIndicacoes.get(posicao).isCirculacaoInadequada());
        txtDescricaoCirculacao.setText(listaContraIndicacoes.get(posicao).getTipoCirculacaoInadequeada());
        
        RMarcaPassoSim.setSelected(listaContraIndicacoes.get(posicao).isMarcaPasso());
        RMarcaPassoNao.setSelected(!listaContraIndicacoes.get(posicao).isMarcaPasso());
        txtDescricaoMarcaPasso.setText(listaContraIndicacoes.get(posicao).getTipoMarcaPasso());
        
        RDiabetesSim.setSelected(listaContraIndicacoes.get(posicao).isDiabetes());
        RDiabetesNao.setSelected(!listaContraIndicacoes.get(posicao).isDiabetes());
        txtDescricaoDiabetes.setText(listaContraIndicacoes.get(posicao).getTipoDiabetes());
    }
    
    public void preencherContraIndicacao() {
        contra.setGravidez(RGravidezSim.isSelected());
        contra.setTipoGravidez(txtDescricaoGravidez.getText().trim());
        
        contra.setCirculacaoInadequada(RCirculacaoInadequadaSim.isSelected());
        contra.setTipoCirculacaoInadequeada(txtDescricaoCirculacao.getText().trim());
        
        contra.setDiabetes(RDiabetesSim.isSelected());
        contra.setTipoDiabetes(txtDescricaoDiabetes.getText().trim());
        
        contra.setHipertensao(RHipertensaoSim.isSelected());
        contra.setTipoHipertensao(txtDescricaoHipertensao.getText().trim());
        
        contra.setMarcaPasso(RMarcaPassoSim.isSelected());
        contra.setTipoMarcaPasso(txtDescricaoMarcaPasso.getText().trim());
        
        contra.setInfeccoesLocais(RInfeccoesLocaisSim.isSelected());
        contra.setTipoInfeccoesLocais(txtDescricaoInfeccoes.getText().trim());
        
        contra.setObservacao(txtObservaçõesGerais.getText());
        
        JOptionPane.showMessageDialog(null, "Contra Indicacoes Salvas");
        
    }
        
    
    public void inicializarTela() {
        cliente = DadosCliente.cliente;
        listaContraIndicacoes = cliente.getListaContraIndicacoes();
             
        limparCampos();
        desativarCampos();
        ativarBotoesIniciar();
    }
    
    public void novo() {
        operacao = 0;
        limparCampos(); //limpa os dados
        ativarCampos();//ativa os campos
        ativarBotoesNovoEditarExcluir();

        //cria um novo funcionário
        //OBS: é ideia colocar o idPessoa(0), pois caso cadastrar mais de um usuário na mesma sessão, não vai da pau.
        contra = new ContraIndicacao();
        contra.setIdContraIndicacao(0);

        txtDescricaoGravidez.requestFocus();
    }
    
    public void cancelar() {
        ativarBotoesIniciar();
        if (posicao < 0) {
            limparCampos();
        } else {
            exibirContraIndicacao();
        }

        desativarCampos();
    }
    
    public void configuracoesIniciaisDados() {
        RGravidezSim.setSelected(true);
        txtDescricaoGravidez.setText("");
        
        RInfeccoesLocaisSim.setSelected(true);
        txtDescricaoInfeccoes.setText("");
        
        RCirculacaoInadequadaSim.setSelected(true);
        txtDescricaoCirculacao.setText("");
        
        RMarcaPassoSim.setSelected(true);
        txtDescricaoMarcaPasso.setText("");
        
        RDiabetesSim.setSelected(true);
        txtDescricaoDiabetes.setText("");
        
        RHipertensaoSim.setSelected(true);
        txtDescricaoHipertensao.setText("");
    }
    
     public void salvar(){
        if(salvarFormulario()){
            operacao = -1;
            limparCampos();
            desativarCampos();
            ativarBotoesIniciar();
        }
        
   }
    public boolean salvarFormulario() {
        if(validarDataConsulta()){
            preencherContraIndicacao();
            contra.setCliente(cliente);

            if(operacao == 0){
                persisteContraIndicacao.salvar(contra);
                listaContraIndicacoes.add(contra);
            }else if(operacao == 1){
                persisteContraIndicacao.atualizar(contra);
            }
            
            return true;
        }
        return false;
        
    }
    public boolean validarDataConsulta() {
        if (Validacoes.validarData(jDateCadastro.getDate(), true)) {
            contra.setDtCadastro(jDateCadastro.getDate());
            return true;
        } else {
            JOptionPane.showMessageDialog(null, "Preencha o campo data corretamente. Ele não pode estar vazio ou ser maior que a "
                    + "data atual.");
            jDateCadastro.requestFocus();
            return false;
        }
    }
    public CadastroContraIndicacao(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        inicializarTela();
    }
    public void pesquisar(){
        if(!listaContraIndicacoes.isEmpty()){
            selecionarContaIndicacao();
            ativarBotoesIniciar();
            exibirContraIndicacao();
        }else{
            JOptionPane.showMessageDialog(null, "Não existe um perfil antropométrico cadastrado para esse funcionário.");
        }
    }
    public void selecionarContaIndicacao(){
        JLabel label = new JLabel("Data do exame:");
        JComboBox combo = new JComboBox();
        Object[] objetos = new Object[]{label, combo};
        
        //preenchendo o combo com os valores da lista
        for(ContraIndicacao item: listaContraIndicacoes){
            combo.addItem(Data.formatoDataConvencional.format(item.getDtCadastro()));
        }
        
        //exibe a mensagem na tela e pega a resposta
        int resposta = JOptionPane.showConfirmDialog(null, objetos, 
                "Selecione uma Contra Indicação pela sua data de cadastro", JOptionPane.OK_CANCEL_OPTION);
        
        //se a resposta for ok, retorna o perfil desejado.
        if(resposta == JOptionPane.OK_OPTION){
            posicao = combo.getSelectedIndex();
            desativarCampos();
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        groupGravidez = new javax.swing.ButtonGroup();
        groupInfeccoesLocais = new javax.swing.ButtonGroup();
        groupCirculacaoInadequada = new javax.swing.ButtonGroup();
        groupMarcaPasso = new javax.swing.ButtonGroup();
        groupDiabetes = new javax.swing.ButtonGroup();
        groupHipertensao = new javax.swing.ButtonGroup();
        jPainelBotoes = new javax.swing.JPanel();
        btnNovo = new javax.swing.JButton();
        btnEditar = new javax.swing.JButton();
        btnExcluir = new javax.swing.JButton();
        btnPesquisar = new javax.swing.JButton();
        btnSalvar = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();
        btnSair = new javax.swing.JButton();
        jPanelDados = new javax.swing.JPanel();
        jLabelGravidez = new javax.swing.JLabel();
        jLabelInfeccaoLocal = new javax.swing.JLabel();
        jLabelDiabetes = new javax.swing.JLabel();
        jLabelCirculacaoInadequada = new javax.swing.JLabel();
        jLabelMarcaPasso = new javax.swing.JLabel();
        RGravidezSim = new javax.swing.JRadioButton();
        RGravidezNao = new javax.swing.JRadioButton();
        RInfeccoesLocaisSim = new javax.swing.JRadioButton();
        RInfeccoesLocaisNao = new javax.swing.JRadioButton();
        RCirculacaoInadequadaSim = new javax.swing.JRadioButton();
        RCirculacaoInadequadaNao = new javax.swing.JRadioButton();
        RMarcaPassoSim = new javax.swing.JRadioButton();
        RMarcaPassoNao = new javax.swing.JRadioButton();
        RDiabetesSim = new javax.swing.JRadioButton();
        RDiabetesNao = new javax.swing.JRadioButton();
        jLabelHipertensao = new javax.swing.JLabel();
        RHipertensaoSim = new javax.swing.JRadioButton();
        RHipertensaoNao = new javax.swing.JRadioButton();
        txtDescricaoGravidez = new javax.swing.JTextField();
        txtDescricaoInfeccoes = new javax.swing.JTextField();
        txtDescricaoCirculacao = new javax.swing.JTextField();
        txtDescricaoMarcaPasso = new javax.swing.JTextField();
        txtDescricaoDiabetes = new javax.swing.JTextField();
        txtDescricaoHipertensao = new javax.swing.JTextField();
        jLabelObservacao = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtObservaçõesGerais = new javax.swing.JTextArea();
        jDateCadastro = new com.toedter.calendar.JDateChooser();
        jLabel1 = new javax.swing.JLabel();
        jMenuBarPrincipal = new javax.swing.JMenuBar();
        jMenuSistema = new javax.swing.JMenu();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenuItem6 = new javax.swing.JMenuItem();
        jSeparator3 = new javax.swing.JPopupMenu.Separator();
        jMenuItem16 = new javax.swing.JMenuItem();
        jMenuItem8 = new javax.swing.JMenuItem();
        jMenuCadastro = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JPopupMenu.Separator();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem9 = new javax.swing.JMenuItem();
        jMenuItem10 = new javax.swing.JMenuItem();
        jMenuItem11 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem12 = new javax.swing.JMenuItem();
        jMenuItem13 = new javax.swing.JMenuItem();
        jMenuItem17 = new javax.swing.JMenuItem();
        jMenuItem14 = new javax.swing.JMenuItem();
        jSeparator4 = new javax.swing.JPopupMenu.Separator();
        jMenuItem15 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("ERP BEUATY CENTER - Contra Indicação");

        jPainelBotoes.setPreferredSize(new java.awt.Dimension(800, 45));

        btnNovo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/beautycenter/img/Novo.png"))); // NOI18N
        btnNovo.setToolTipText("NOVO");
        btnNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNovoActionPerformed(evt);
            }
        });

        btnEditar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/beautycenter/img/Editar.png"))); // NOI18N
        btnEditar.setToolTipText("ALTERAR");
        btnEditar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditarActionPerformed(evt);
            }
        });

        btnExcluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/beautycenter/img/Excluir.png"))); // NOI18N
        btnExcluir.setToolTipText("EXCLUIR");
        btnExcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExcluirActionPerformed(evt);
            }
        });

        btnPesquisar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/beautycenter/img/Pesquisar.png"))); // NOI18N
        btnPesquisar.setToolTipText("PESQUISAR");
        btnPesquisar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPesquisarActionPerformed(evt);
            }
        });

        btnSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/beautycenter/img/Salvar.png"))); // NOI18N
        btnSalvar.setToolTipText("SALVAR");
        btnSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalvarActionPerformed(evt);
            }
        });

        btnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/beautycenter/img/Cancelar.png"))); // NOI18N
        btnCancelar.setToolTipText("CANCELAR");
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        btnSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/beautycenter/img/Sair.png"))); // NOI18N
        btnSair.setToolTipText("SAIR");
        btnSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSairActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPainelBotoesLayout = new javax.swing.GroupLayout(jPainelBotoes);
        jPainelBotoes.setLayout(jPainelBotoesLayout);
        jPainelBotoesLayout.setHorizontalGroup(
            jPainelBotoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 800, Short.MAX_VALUE)
            .addGroup(jPainelBotoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPainelBotoesLayout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(btnNovo)
                    .addGap(5, 5, 5)
                    .addComponent(btnEditar)
                    .addGap(5, 5, 5)
                    .addComponent(btnExcluir)
                    .addGap(5, 5, 5)
                    .addComponent(btnPesquisar)
                    .addGap(5, 5, 5)
                    .addComponent(btnSalvar)
                    .addGap(5, 5, 5)
                    .addComponent(btnCancelar)
                    .addGap(5, 5, 5)
                    .addComponent(btnSair)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );
        jPainelBotoesLayout.setVerticalGroup(
            jPainelBotoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 45, Short.MAX_VALUE)
            .addGroup(jPainelBotoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPainelBotoesLayout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addGroup(jPainelBotoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(btnNovo)
                        .addComponent(btnEditar)
                        .addComponent(btnExcluir)
                        .addComponent(btnPesquisar)
                        .addComponent(btnSalvar)
                        .addComponent(btnCancelar)
                        .addComponent(btnSair))
                    .addGap(0, 0, Short.MAX_VALUE)))
        );

        jPanelDados.setBackground(new java.awt.Color(255, 255, 255));

        jLabelGravidez.setText("GRAVIDEZ:");

        jLabelInfeccaoLocal.setText("INFECÇÕES LOCAIS:");

        jLabelDiabetes.setText("DIABETES:");

        jLabelCirculacaoInadequada.setText("CIRCULAÇÃO INADEQUADA:");

        jLabelMarcaPasso.setText("MARCA PASSO:");

        RGravidezSim.setBackground(new java.awt.Color(255, 255, 255));
        groupGravidez.add(RGravidezSim);
        RGravidezSim.setText("SIM");
        RGravidezSim.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                RGravidezSimItemStateChanged(evt);
            }
        });

        RGravidezNao.setBackground(new java.awt.Color(255, 255, 255));
        groupGravidez.add(RGravidezNao);
        RGravidezNao.setText("NÃO");

        RInfeccoesLocaisSim.setBackground(new java.awt.Color(255, 255, 255));
        groupInfeccoesLocais.add(RInfeccoesLocaisSim);
        RInfeccoesLocaisSim.setText("SIM");
        RInfeccoesLocaisSim.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                RInfeccoesLocaisSimItemStateChanged(evt);
            }
        });

        RInfeccoesLocaisNao.setBackground(new java.awt.Color(255, 255, 255));
        groupInfeccoesLocais.add(RInfeccoesLocaisNao);
        RInfeccoesLocaisNao.setText("NÃO");

        RCirculacaoInadequadaSim.setBackground(new java.awt.Color(255, 255, 255));
        groupCirculacaoInadequada.add(RCirculacaoInadequadaSim);
        RCirculacaoInadequadaSim.setText("SIM");
        RCirculacaoInadequadaSim.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                RCirculacaoInadequadaSimItemStateChanged(evt);
            }
        });

        RCirculacaoInadequadaNao.setBackground(new java.awt.Color(255, 255, 255));
        groupCirculacaoInadequada.add(RCirculacaoInadequadaNao);
        RCirculacaoInadequadaNao.setText("NÃO");

        RMarcaPassoSim.setBackground(new java.awt.Color(255, 255, 255));
        groupMarcaPasso.add(RMarcaPassoSim);
        RMarcaPassoSim.setText("SIM");
        RMarcaPassoSim.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                RMarcaPassoSimItemStateChanged(evt);
            }
        });

        RMarcaPassoNao.setBackground(new java.awt.Color(255, 255, 255));
        groupMarcaPasso.add(RMarcaPassoNao);
        RMarcaPassoNao.setText("NÃO");

        RDiabetesSim.setBackground(new java.awt.Color(255, 255, 255));
        groupDiabetes.add(RDiabetesSim);
        RDiabetesSim.setText("SIM");
        RDiabetesSim.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                RDiabetesSimItemStateChanged(evt);
            }
        });

        RDiabetesNao.setBackground(new java.awt.Color(255, 255, 255));
        groupDiabetes.add(RDiabetesNao);
        RDiabetesNao.setText("NÃO");

        jLabelHipertensao.setText("HIPERTENSÃO:");

        RHipertensaoSim.setBackground(new java.awt.Color(255, 255, 255));
        groupHipertensao.add(RHipertensaoSim);
        RHipertensaoSim.setText("SIM");
        RHipertensaoSim.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                RHipertensaoSimItemStateChanged(evt);
            }
        });

        RHipertensaoNao.setBackground(new java.awt.Color(255, 255, 255));
        groupHipertensao.add(RHipertensaoNao);
        RHipertensaoNao.setText("NÃO");

        jLabelObservacao.setText("OBSERVAÇÕES:");

        txtObservaçõesGerais.setColumns(20);
        txtObservaçõesGerais.setRows(5);
        jScrollPane1.setViewportView(txtObservaçõesGerais);

        jLabel1.setText("Data Cadastro:");

        javax.swing.GroupLayout jPanelDadosLayout = new javax.swing.GroupLayout(jPanelDados);
        jPanelDados.setLayout(jPanelDadosLayout);
        jPanelDadosLayout.setHorizontalGroup(
            jPanelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelDadosLayout.createSequentialGroup()
                .addGroup(jPanelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 737, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanelDadosLayout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(jPanelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabelGravidez, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabelInfeccaoLocal, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabelCirculacaoInadequada, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabelMarcaPasso, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabelDiabetes, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabelHipertensao)))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanelDadosLayout.createSequentialGroup()
                                    .addGroup(jPanelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(RMarcaPassoSim)
                                        .addComponent(RCirculacaoInadequadaSim)
                                        .addComponent(RDiabetesSim)
                                        .addComponent(RInfeccoesLocaisSim)
                                        .addComponent(RHipertensaoSim)
                                        .addComponent(RGravidezSim))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(jPanelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(RGravidezNao, javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(RInfeccoesLocaisNao, javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(RCirculacaoInadequadaNao, javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(RMarcaPassoNao, javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(RDiabetesNao, javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(RHipertensaoNao, javax.swing.GroupLayout.Alignment.TRAILING))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(jPanelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(txtDescricaoDiabetes, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE)
                                        .addComponent(txtDescricaoMarcaPasso, javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(txtDescricaoCirculacao, javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(txtDescricaoInfeccoes, javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(txtDescricaoGravidez, javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(txtDescricaoHipertensao)))
                                .addComponent(jDateCadastro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(jPanelDadosLayout.createSequentialGroup()
                            .addGap(25, 25, 25)
                            .addComponent(jLabelObservacao))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanelDadosLayout.setVerticalGroup(
            jPanelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelDadosLayout.createSequentialGroup()
                .addGap(9, 9, 9)
                .addGroup(jPanelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelGravidez)
                    .addComponent(RGravidezSim)
                    .addComponent(RGravidezNao)
                    .addComponent(txtDescricaoGravidez, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelInfeccaoLocal)
                    .addComponent(RInfeccoesLocaisSim)
                    .addComponent(RInfeccoesLocaisNao)
                    .addComponent(txtDescricaoInfeccoes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelCirculacaoInadequada)
                    .addComponent(RCirculacaoInadequadaSim)
                    .addComponent(RCirculacaoInadequadaNao)
                    .addComponent(txtDescricaoCirculacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(2, 2, 2)
                .addGroup(jPanelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMarcaPasso)
                    .addComponent(RMarcaPassoSim)
                    .addComponent(RMarcaPassoNao)
                    .addComponent(txtDescricaoMarcaPasso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelDiabetes)
                    .addComponent(RDiabetesSim)
                    .addComponent(RDiabetesNao)
                    .addComponent(txtDescricaoDiabetes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelHipertensao)
                    .addComponent(RHipertensaoSim)
                    .addComponent(RHipertensaoNao)
                    .addComponent(txtDescricaoHipertensao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jDateCadastro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(14, 14, 14)
                .addComponent(jLabelObservacao)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(88, Short.MAX_VALUE))
        );

        jMenuSistema.setText("Sistema");

        jMenuItem7.setText("Agenda");
        jMenuSistema.add(jMenuItem7);

        jMenuItem6.setText("Suporte - Contatos");
        jMenuSistema.add(jMenuItem6);
        jMenuSistema.add(jSeparator3);

        jMenuItem16.setText("Versão");
        jMenuSistema.add(jMenuItem16);

        jMenuItem8.setText("Sair");
        jMenuSistema.add(jMenuItem8);

        jMenuBarPrincipal.add(jMenuSistema);

        jMenuCadastro.setText("Cadastros");

        jMenuItem1.setText("Funcionario");
        jMenuCadastro.add(jMenuItem1);

        jMenuItem2.setText("Paciente");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenuCadastro.add(jMenuItem2);
        jMenuCadastro.add(jSeparator1);

        jMenuItem3.setText("Cargos");
        jMenuCadastro.add(jMenuItem3);

        jMenuItem4.setText("Tratamentos");
        jMenuCadastro.add(jMenuItem4);
        jMenuCadastro.add(jSeparator2);

        jMenuItem5.setText("Produtos");
        jMenuCadastro.add(jMenuItem5);

        jMenuBarPrincipal.add(jMenuCadastro);

        jMenu1.setText("Relatorios");
        jMenuBarPrincipal.add(jMenu1);

        jMenu2.setText("Pesquisar");

        jMenuItem9.setText("Contra Indicações");
        jMenu2.add(jMenuItem9);

        jMenuItem10.setText("Perfil Antropometrico");
        jMenu2.add(jMenuItem10);

        jMenuItem11.setText("Exames Fisicos");
        jMenu2.add(jMenuItem11);

        jMenuBarPrincipal.add(jMenu2);

        jMenu3.setText("Financeiro");

        jMenuItem12.setText("Retirada do Caixa");
        jMenu3.add(jMenuItem12);

        jMenuItem13.setText("Suprimento do Caixa");
        jMenu3.add(jMenuItem13);

        jMenuItem17.setText("Recebimento Extra");
        jMenu3.add(jMenuItem17);

        jMenuItem14.setText("Fechamento Diario");
        jMenu3.add(jMenuItem14);
        jMenu3.add(jSeparator4);

        jMenuItem15.setText("Fechamento de Funcionarios");
        jMenu3.add(jMenuItem15);

        jMenuBarPrincipal.add(jMenu3);

        setJMenuBar(jMenuBarPrincipal);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPainelBotoes, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanelDados, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPainelBotoes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanelDados, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void btnNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNovoActionPerformed
        novo();
    }//GEN-LAST:event_btnNovoActionPerformed

    private void btnEditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditarActionPerformed
        editar();
    }//GEN-LAST:event_btnEditarActionPerformed

    private void btnExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExcluirActionPerformed
        if(posicao < 0){
            JOptionPane.showMessageDialog(null, "Selecione uma Contra Indicação para excluir.");
        }else{
            int resposta = JOptionPane.showConfirmDialog(null, "Deseja realmente excluir essa Contra Indicação?");
            if(resposta == JOptionPane.OK_OPTION){
                //excluir();
            }else{
                //cancelar();
            }
        }

    }//GEN-LAST:event_btnExcluirActionPerformed

    private void btnPesquisarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPesquisarActionPerformed
       pesquisar();
    }//GEN-LAST:event_btnPesquisarActionPerformed

    private void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed
       salvar();
    }//GEN-LAST:event_btnSalvarActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        cancelar();
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void btnSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSairActionPerformed
        dispose();
    }//GEN-LAST:event_btnSairActionPerformed

    private void RGravidezSimItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_RGravidezSimItemStateChanged
        ativarCampo(RGravidezSim, txtDescricaoGravidez);
    }//GEN-LAST:event_RGravidezSimItemStateChanged

    private void RInfeccoesLocaisSimItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_RInfeccoesLocaisSimItemStateChanged
        ativarCampo(RInfeccoesLocaisSim, txtDescricaoInfeccoes);
    }//GEN-LAST:event_RInfeccoesLocaisSimItemStateChanged

    private void RCirculacaoInadequadaSimItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_RCirculacaoInadequadaSimItemStateChanged
        ativarCampo(RCirculacaoInadequadaSim, txtDescricaoCirculacao);
    }//GEN-LAST:event_RCirculacaoInadequadaSimItemStateChanged

    private void RMarcaPassoSimItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_RMarcaPassoSimItemStateChanged
        ativarCampo(RMarcaPassoSim, txtDescricaoMarcaPasso);
    }//GEN-LAST:event_RMarcaPassoSimItemStateChanged

    private void RDiabetesSimItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_RDiabetesSimItemStateChanged
        ativarCampo(RDiabetesSim, txtDescricaoDiabetes);
    }//GEN-LAST:event_RDiabetesSimItemStateChanged

    private void RHipertensaoSimItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_RHipertensaoSimItemStateChanged
        ativarCampo(RHipertensaoSim, txtDescricaoHipertensao);
    }//GEN-LAST:event_RHipertensaoSimItemStateChanged

    /**
     * @param args the command line arguments
     */
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JRadioButton RCirculacaoInadequadaNao;
    private javax.swing.JRadioButton RCirculacaoInadequadaSim;
    private javax.swing.JRadioButton RDiabetesNao;
    private javax.swing.JRadioButton RDiabetesSim;
    private javax.swing.JRadioButton RGravidezNao;
    private javax.swing.JRadioButton RGravidezSim;
    private javax.swing.JRadioButton RHipertensaoNao;
    private javax.swing.JRadioButton RHipertensaoSim;
    private javax.swing.JRadioButton RInfeccoesLocaisNao;
    private javax.swing.JRadioButton RInfeccoesLocaisSim;
    private javax.swing.JRadioButton RMarcaPassoNao;
    private javax.swing.JRadioButton RMarcaPassoSim;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnEditar;
    private javax.swing.JButton btnExcluir;
    private javax.swing.JButton btnNovo;
    private javax.swing.JButton btnPesquisar;
    private javax.swing.JButton btnSair;
    private javax.swing.JButton btnSalvar;
    private javax.swing.ButtonGroup groupCirculacaoInadequada;
    private javax.swing.ButtonGroup groupDiabetes;
    private javax.swing.ButtonGroup groupGravidez;
    private javax.swing.ButtonGroup groupHipertensao;
    private javax.swing.ButtonGroup groupInfeccoesLocais;
    private javax.swing.ButtonGroup groupMarcaPasso;
    private com.toedter.calendar.JDateChooser jDateCadastro;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabelCirculacaoInadequada;
    private javax.swing.JLabel jLabelDiabetes;
    private javax.swing.JLabel jLabelGravidez;
    private javax.swing.JLabel jLabelHipertensao;
    private javax.swing.JLabel jLabelInfeccaoLocal;
    private javax.swing.JLabel jLabelMarcaPasso;
    private javax.swing.JLabel jLabelObservacao;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBarPrincipal;
    private javax.swing.JMenu jMenuCadastro;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem10;
    private javax.swing.JMenuItem jMenuItem11;
    private javax.swing.JMenuItem jMenuItem12;
    private javax.swing.JMenuItem jMenuItem13;
    private javax.swing.JMenuItem jMenuItem14;
    private javax.swing.JMenuItem jMenuItem15;
    private javax.swing.JMenuItem jMenuItem16;
    private javax.swing.JMenuItem jMenuItem17;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JMenu jMenuSistema;
    private javax.swing.JPanel jPainelBotoes;
    private javax.swing.JPanel jPanelDados;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JPopupMenu.Separator jSeparator3;
    private javax.swing.JPopupMenu.Separator jSeparator4;
    private javax.swing.JTextField txtDescricaoCirculacao;
    private javax.swing.JTextField txtDescricaoDiabetes;
    private javax.swing.JTextField txtDescricaoGravidez;
    private javax.swing.JTextField txtDescricaoHipertensao;
    private javax.swing.JTextField txtDescricaoInfeccoes;
    private javax.swing.JTextField txtDescricaoMarcaPasso;
    private javax.swing.JTextArea txtObservaçõesGerais;
    // End of variables declaration//GEN-END:variables
}
